// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

.chat-conversation-list-item {
  @edge-margin: 10px; // margin between elements and side of list container.
  @indicator-width: 2px;
  @tile-margin: 10px; // gap for the indicator and close button.
  @top: chat-conversation-list-item;

  height: 40px;
  color: white;
  display: flex;
  align-items: center;
  margin-left: @edge-margin;
  padding-left: @tile-margin;
  font-size: @font-size--title-small;
  position: relative;

  @media @desktop {
    &:hover {
      background: linear-gradient(
        to right,
        @osu-colour-b5 @tile-margin,
        @osu-colour-b3 33%,
        @osu-colour-b3 100%
      );
    }
  }

  @media @mobile {
    margin-left: 0;
    padding-left: 0;
  }

  &--selected {
    color: white;
    background: linear-gradient(
      to right,
      @osu-colour-b5 @tile-margin,
      @osu-colour-b4 33%,
      @osu-colour-b4 100%
    );
    @media @mobile {
      background: @osu-colour-b4;
    }
  }

  &__close-button {
    .reset-input();
    padding: 5px;
    color: fade(white, 50%);

    &:hover {
      color: white;
    }

    @media @desktop {
      position: absolute;
      opacity: 0;
      height: 100%;
      margin-left: -@tile-margin;

      .@{top}:hover & {
        opacity: 1;
      }
    }

    @media @mobile {
      display: none;

      .@{top}--selected & {
        display: block;
        margin-left: 5px;
      }
    }
  }

  &__tile {
    .reset-input();
    display: flex;
    align-items: center;
    align-self: stretch;
    flex: 1;
    margin-left: @tile-margin;
    min-width: 0;

    @media @mobile {
      margin-left: @indicator-width * 2;
    }
  }

  &__unread-indicator {
    position: absolute;
    background: @green;
    width: @indicator-width;
    height: 10px;
    border-radius: 1px;
    pointer-events: none;

    &::after {
      opacity: 0.5;
      .full-size();
      border-radius: 1px;
      content: "";
      box-shadow: 0 0 5px lighten(@green, 10%);
      animation: glow-pulse 2s infinite;
    }

    @media @desktop {
      margin-left: -$width;

      .@{top}:hover & {
        opacity: 0;
      }
    }

    @media @mobile {
      margin-left: @indicator-width;
    }
  }

  &__name {
    flex: 1;
    text-align: left;

    @media @mobile {
      display: none;

      .@{top}--selected & {
        display: block;
        padding-right: @tile-margin;
      }
    }
  }

  &__chevron {
    margin-right: @edge-margin;
    color: white;
    opacity: 0;

    .@{top}--selected & {
      opacity: 1;
    }

    @media @mobile {
      display: none;
    }
  }

  &__avatar {
    width: 30px;
    height: 30px;
    margin-right: 10px;
    flex-shrink: 0;

    @media @mobile {
      margin: 0 5px;
    }
  }
}
